﻿using System;
using System.IO;
using System.Windows;
using System.Windows.Input;
using churchtool.ViewModel;
using churchtool.Data;

namespace churchtool.Operations.Commands
{
    class SaveSettingsCommand : ICommand
    {
        #region Fields

        // Member variables
        private SettingsWindowViewModel m_ViewModel;

        #endregion

        #region Constructor

        /// <summary>
        /// Default constructor.
        /// </summary>
        public SaveSettingsCommand(SettingsWindowViewModel viewModel)
        {
            m_ViewModel = viewModel;
        }

        #endregion

        #region ICommand Members

        /// <summary>
        /// Whether the DoBrowseFilesCommand is enabled.
        /// </summary>
        public bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>
        /// Actions to take when CanExecute() changes.
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        /// <summary>
        /// Executes the DoBrowseFilesCommand
        /// </summary>
        public void Execute(object parameter)
        {
            GlobalSettings.SerializeToXML();
        }

        #endregion
    }
}
